// pages/zixun/zixun.js
import cache from '../../utils/Cache.js';
import url from '../../utils/url.js';
import http from '../../utils/http.js';
Page({

  /**
   * 页面的初始数据
   */
  data: {
      article_list : [],
      page:1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getArticleList();
  },
  getArticleList:function(evt){
    let that = this;
    let page = that.data.page;
    // 显示加载图标
    wx.showLoading({
      title: '玩命加载中',
    })
    http.http(url.articleList, 'GET', {page}, function (res) {
      console.log(res.data)
      if(res.data.length > 0){
        page++;
        that.setData({
          article_list: [...that.data.article_list,...res.data]
        });
      }else{
          wx.showToast({
            title: '暂无更多',
            icon: 'none',
          })
      }
      wx.hideLoading();
    });
  },
  onReachBottom:function(){
    var that = this;
    that.data.page++;
    that.getArticleList();
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  }
 
})